home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkTabPanel.h.z / VkTabPanel.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  7.0 KB  |  210 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  3. //                                                                            //
  4. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  5. // the contents of this file may not be disclosed to third parties, copied    //
  6. // or duplicated in any form, in whole or in part, without the prior written  //
  7. // permission of Silicon Graphics, Inc.                                       //
  8. //                                                                            //
  9. // RESTRICTED RIGHTS LEGEND:                                                  //
  10. // Use,duplication or disclosure by the Government is subject to restrictions //
  11. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  12. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  13. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  14. // rights reserved under the Copyright Laws of the United States.             //
  15. //                                                                            //
  16. ////////////////////////////////////////////////////////////////////////////////
  17. #ifndef VKTABPANEL_H
  18. #define VKTABPANEL_H
  19.  
  20. #include <Vk/VkComponent.h>
  21. #include <Vk/VkDoubleBuffer.h>
  22.  
  23. typedef struct {
  24.   char *label;
  25.   void *clientData;
  26.   int tabIndex;
  27.   XEvent *event;
  28. } VkTabCallbackStruct;
  29.  
  30. class VkTabArea;
  31. class VkPopupMenu;
  32.  
  33. class VkTabPanel : public VkComponent {
  34.  
  35.   public:
  36.  
  37.     static const char *const tabSelectCallback;
  38.     static const char *const tabPopupCallback;
  39.     
  40.     VkTabPanel(const char *name, Widget parent,
  41.            Boolean horizOrientation = True,
  42.            int tabHeight = 0);
  43.     ~VkTabPanel();
  44.     
  45.     virtual const char* className();
  46.     
  47.     Boolean horiz();
  48.     Boolean uniformTabs();
  49.     int size();
  50.     Pixel tabBg();
  51.     Pixel selectedTabBg();
  52.     Pixel labelFg();
  53.     Pixel labelBg();
  54.     GC gc();            // Obsolete
  55.     Pixel getSelectedTabBg(), getSelectedTabTs(), getUnselectedTabBg();
  56.     int lineThickness();
  57.     int tabHeight();
  58.     
  59.     int selectedTab();
  60.     
  61.     Widget area1() { return _area1; }
  62.     Widget area2() { return _area2; }
  63.     
  64.     Boolean getTab(int index, char **label_return, void **clientData_return);
  65.     
  66.     int addTab(char *label, void *clientData, Boolean sorted = False);
  67.     void addTabs(char **labels, void **clientDatas, int numLabels,
  68.          Boolean sorted = False);
  69.     
  70.     void addTabs(char *list);   // Mostly for rapidapp, add a comma-separated list of tabs
  71.     void setOrientation(int orientation); // XmHORIZONTAL or XmVERTICAL
  72.     
  73.     Boolean selectTab(int index, XEvent *event = NULL);
  74.     Boolean selectTab(char *label, XEvent *event = NULL);
  75.     
  76.     Boolean removeTab(int index);
  77.     Boolean removeTab(char *label);
  78.     
  79.     Boolean tabPixmap(int index, Pixmap *pixmap_return);
  80.     Boolean tabPixmap(char *label, Pixmap *pixmap_return);
  81.     Boolean setTabPixmap(int index, Pixmap pixmap);
  82.     Boolean setTabPixmap(char *label, Pixmap pixmap);
  83.     Boolean setTabLabel(int index, char *label);
  84.     Boolean setTabClientData(int index, void *clientData);
  85.     
  86.     static VkComponent *CreateVkTabPanel(const char *name, Widget parent);
  87.     
  88.   protected:
  89.     
  90.     void tabSelect(VkComponent *comp, void *clientData, void *callData);
  91.     void tabPopup(VkComponent *comp, void *clientData, void *callData);
  92.     
  93.     Widget _area1, _area2, _outer1, _outer2, _marg1, _marg2;
  94.     VkTabArea *_tabArea;
  95.     int _margin, _margin1, _margin2;
  96.     Pixel _tabBg;
  97. }; 
  98.  
  99. /**********************************************************************/
  100. /*         VkTabArea is a private class used by VkTabPanel            */
  101. /**********************************************************************/
  102.  
  103. typedef struct {
  104.   char *ascii;
  105.   void *clientData;
  106.   XmString label;
  107.   int width;
  108.   Pixmap pixmap;
  109.   unsigned int pwidth, pheight, pdepth;
  110. } VkTabInfo;
  111.  
  112. class VkTabArea : public VkDoubleBuffer {
  113. public:
  114.  
  115.   static const char *const tabSelectCallback;
  116.   static const char *const tabPopupCallback;
  117.  
  118.   VkTabArea(const char *name, Widget parent,
  119.         Boolean horizOrientation = True,
  120.         int tabHeight = 0);
  121.   ~VkTabArea();
  122.  
  123.   virtual const char* className();
  124.  
  125.   Boolean horiz() { return _horiz; }
  126.  
  127.   void setHoriz(Boolean horiz) { _horiz = horiz;}
  128.  
  129.   Boolean uniformTabs() { return _uniform; }
  130.   int size() { return _numInfo; }
  131.   Pixel selectedTabBg() { return _selectedTabBg; }
  132.   Pixel unselectedTabBg();
  133.   Pixel selectedTabTs();
  134.   Pixel labelFg() { return _labelFg; }
  135.   Pixel labelBg() { return _labelBg; }
  136.   GC gc() { return _gc; }  // Obsolete -- use selectedGC() or unselectedGC()
  137.   GC selectedGC(), unselectedGC();
  138.   int lineThickness() { return _lineThickness; }
  139.   int tabHeight() { return _tabHeight; }
  140.  
  141.   int selectedTab() { return _selected; }
  142.  
  143.   Boolean getTab(int index, char **label_return, void **clientData_return);
  144.  
  145.   int addTab(char *label, void *clientData, Boolean sorted = False);
  146.   void addTabs(char **labels, void **clientDatas, int numLabels,
  147.            Boolean sorted = False);
  148.  
  149.   Boolean selectTab(int index, XEvent *event = NULL);
  150.   Boolean selectTab(char *label, XEvent *event = NULL);
  151.  
  152.   Boolean removeTab(int index);
  153.   Boolean removeTab(char *label);
  154.  
  155.   Boolean tabPixmap(int index, Pixmap *pixmap_return);
  156.   Boolean tabPixmap(char *label, Pixmap *pixmap_return);
  157.   Boolean setTabPixmap(int index, Pixmap pixmap);
  158.   Boolean setTabPixmap(char *label, Pixmap pixmap);
  159.   Boolean setTabLabel(int index, char *label);
  160.   Boolean setTabClientData(int index, void *clientData);
  161.  
  162. protected:
  163.   virtual void draw();
  164.   virtual void resize();
  165.   void scheduleUpdate();
  166.   void drawTab(int index, Boolean selected = False);
  167.   void input(XEvent *event);
  168.   int findLabel(char *label);
  169.   int findTab(int x, int y);
  170.   Boolean matchTab(int index, int x, int y);
  171.   int tabWidth(int index);
  172.   int computeWidth(int index);
  173.   int tabOffset(int index);
  174.   void computeTabLayout();
  175.   int computeEndTab(int startIndex);
  176.   void drawLeftEnd();
  177.   void drawRightEnd();
  178.   void postMenu(XButtonEvent *event, Boolean right);
  179.   void menuSelect(Widget w);
  180.   void createTabMenu();
  181.   void tabsChanged();
  182.   void invalidateMenu();
  183.   void curveCorner(int x, int y, int dx, int dy, XPoint *points);
  184.  
  185.   static void input_stub(Widget w, XtPointer clientData, XtPointer callData);
  186.   static void menu_stub(Widget w, XtPointer clientData, XtPointer callData);
  187.   static Boolean update_stub(XtPointer clientData);
  188.  
  189.   Widget _label;
  190.   Boolean _horiz, _uniform;
  191.   int _numInfo, _sizeInfo;
  192.   VkTabInfo *_info;
  193.   Pixel _selectedTabBg, _labelBg, _labelFg;
  194.   Dimension _marginWidth, _marginHeight, _tabHeight;
  195.   XmFontList _fontList;
  196.   int _lineThickness, _sideOffset, _endSpacing, _endMultiplier, _pixmapSpacing;
  197.   int _curvature, _curveMultiplier;
  198.   GC _gc, _gcErase, _gcSelected;
  199.   int _selected;
  200.   XtWorkProcId _updateId;
  201.   int _startTab, _endTab;
  202.   Boolean _freezeLayout;
  203.   VkPopupMenu *_tabMenu;
  204.   int _maxWidth, _vertHeight;
  205.   int _leftMenuOffset, _rightMenuOffset;
  206.   XFontStruct *_fs;
  207. };
  208.  
  209. #endif
  210.